package com.industrial.system.api;

import cn.hutool.core.lang.tree.Tree;
import com.industrial.common.core.web.domain.AjaxResult;
import com.industrial.system.api.domain.BizAccountMapping;
import com.industrial.system.api.domain.RegisterWhiteUserForm;
import com.industrial.system.api.domain.SysDept;
import com.industrial.system.api.domain.SysUser;
import com.industrial.system.api.factory.RemoteUserFallbackFactory;
import com.industrial.system.api.model.LoginUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import com.industrial.common.core.constant.SecurityConstants;
import com.industrial.common.core.constant.ServiceNameConstants;
import com.industrial.common.core.domain.R;

import java.util.List;
import java.util.Map;

/**
 * 用户服务
 * 
 * @author ttql
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
//@FeignClient(name = "remoteUserService", url = "http://100.89.64.135:9009", fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService
{
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
    public R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
    public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @PostMapping("/user/getCurrentUserNameExist")
    public R<List<SysUser>> getCurrentUserNameExist(@RequestBody List<String> uscc);

    /**
     * <p>
     *     查询所有的管理员用户
     * </p>
     * @return 结果
     */
    @GetMapping("/user/selectAdminUserList")
    public R<List<SysUser>> selectAdminUserList();

    @GetMapping("/user/info/userid/{userId}")
    public R<SysUser> getUserInfoByUserId(@PathVariable("userId")String userId);

    @GetMapping("/user/getAdminUserList")
    public R<List<SysUser>> getAdminUserList();

    @GetMapping("/user/getAdminUserInfoByAppointUserId/{userId}")
    public R<SysUser> getAdminUserInfoByAppointUserId(@PathVariable("userId") String userId);

    @PutMapping("/user")
    public AjaxResult updateAdministorUser(SysUser sysUser);

    @DeleteMapping("/user/del/{userIds}")
    public AjaxResult removeUserByUserId(@PathVariable("userIds") String userIds);

    @PostMapping("/user")
    public AjaxResult insertNewUser(SysUser user);

    @PostMapping("/user/clearAdminUserInfo")
    public R<Boolean> clearAdminUserInfo(@RequestBody SysUser sysUser);

    @PostMapping("/batchUpdatetUser")
    public R<List<SysUser>> batchUpdatetUser(@RequestBody List<SysUser> uscc);

    @PostMapping("/batchInsertUser")
    public R<List<SysUser>> batchInsertUser(@RequestBody List<SysUser> uscc);

    @PostMapping("/user/queryUserInfoByUserIds")
    public R<List<SysUser>> queryUserInfoByUserIds(@RequestBody List<String> userIdList);

    @PostMapping("/user/queryDeptName")
    public R<List<SysDept>> queryDeptName(@RequestBody List<String> userIds);


    /**
     * <p>
     *     通过传入的用户ID查询该用户所在部门下的所有用户
     * </p>
     * @param userId 用户ID
     * @return
     */
    @GetMapping("/user/queryUserInDeptAllUser/{userId}")
    public R<List<SysUser>> queryUserInDeptAllUser(@PathVariable("userId") String userId);

    /**
     * <p>
     *     注册白名单用户
     * </p>
     * @param sysUser
     * @return
     */
    @PostMapping("/user/registerWithUser")
    public R<Boolean> registerWithUser(@RequestBody RegisterWhiteUserForm params);

    /**
     * 更新白名单用户角色为白名单企业角色
     * @param sysUser
     * @return
     */

    @PostMapping("/user/updateWhiteUserRole")
    public R<Boolean> updateWhiteUserRole(@RequestBody SysUser sysUser);

    @PostMapping("/user/insertUserRole")
    public R<Boolean> insertUserRole(@RequestBody SysUser sysUser);

    /**
     * 通过用户ID查询部门ID和部门名称
     * @param userIds
     * @return
     */
    @PostMapping("/user/queryDeptIdAndDeptNameByUserId")
    public R<Map<String,String>> queryDeptIdAndDeptNameByUserId(@RequestBody List<String> userIds);

    @GetMapping("/area/queryAreaCodeByAreaName/{areaName}")
    public R<List<String>> queryAreaCodeByAreaName(@PathVariable("areaName") String areaName);

    //======================= 统一认证平台 =======================
    @GetMapping("/cnm/selectUserMappingInfoByZwfwuuid")
    public R<LoginUser> selectUserMappingInfoByZwfwuuid(@RequestParam Map<String, Object> userInfoMap);

    @GetMapping("/cnm/cnnnnn/{uuid}/{uscc}")
    public R<Map<String,Object>> selectSuserToBizUser(@PathVariable("uuid") String uuid,@PathVariable("uscc") String username);

    @GetMapping("/cnm/querySdtUserBingBizUserStatus/{sUserId}")
    public R<LoginUser> querySdtUserBingBizUserStatus(@PathVariable("sUserId") String sUserId);

    @GetMapping("/cnm/sdtUserBindBizUser")
    public R<LoginUser> sdtUserBindBizUser(@RequestBody BizAccountMapping sysUser);
}
